<script setup>
import { PlusOutlined, SearchOutlined, RedoOutlined } from '@ant-design/icons-vue'
import { ref } from 'vue'
const emits = defineEmits(['add', 'init', 'search'])
const schVal = ref('')
const typeVal = ref(null)
// 一级字典列表
const dictList = ref(window.config.dictList)
// 新增按钮点击
const add = () => {
  emits('add')
}
// 刷新
const init = () => {
  schVal.value = ''
  typeVal.value = null
  emits('init')
}
// 搜索
const search = () => {
  emits('search', { constLabel: schVal.value ?? null, type: typeVal.value ?? null })
}
</script>

<template>
  <div class="head">
    <AButton type="primary" @click="add"> <PlusOutlined /> 新增 </AButton>
    <div class="right">
      <ASelect
        @change="search"
        allowClear
        :options="dictList"
        class="com-ipt"
        v-model:value="typeVal"
        placeholder="请选择所属字典"
      />
      <!-- <a-input v-model:value="schVal" placeholder="请输入查询" class="com-ipt" allowClear>
        <template #suffix>
          <SearchOutlined />
        </template>
      </a-input> -->
      <AButton type="primary" @click="search"> <SearchOutlined /> 搜索 </AButton>
      <AButton type="primary" @click="init"> <RedoOutlined /> 刷新 </AButton>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.head {
  display: flex;
  gap: 8px;
  justify-content: space-between;

  .right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
}
</style>